package com.struts.web.corpor.manage.infomanage;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.base.Constants;
import com.lg.system.CLGAction;
import com.struts.deal.corpor.manage.infomanage.InfoDeal;

public class EditInfoAction extends CLGAction {
     
	
	public ActionForward execute(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
		EditInfoForm aWebForm = (EditInfoForm)actionForm;
		ActionMessages msgs = new ActionMessages();
		boolean result = false;
		
		if(aWebForm.getMethod()!=null && aWebForm.getMethod().equals("edit")){
			result=InfoDeal.editInfo(request, response, aWebForm);
			if(result==true){
				return actionMapping.findForward("nbsuccess");
			}else{
				msgs.add("commonMsgs",new ActionMessage(Constants.EDIT_FAIL));
				saveErrors(request,msgs);
			    return actionMapping.findForward("fail");
			}
		}else{
			InfoDeal.loadInfo(request, response, aWebForm);
			return actionMapping.getInputForward();
		}
		
		
	 }
	
}
